package com.example.xposedtest;

import android.util.Log;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class HookLogic implements IXposedHookLoadPackage {
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {

        XposedBridge.log("HookLogic >> current package:" + lpparam.packageName);

        if ("com.example.activitytest".equals(lpparam.packageName)) {
            try {
                XposedBridge.log("HookLogic >> current classLoader:" + lpparam.classLoader);
                XposedHelpers.findAndHookMethod("com.example.activitytest.FirstActivity", lpparam.classLoader, "getInfo", new XC_MethodReplacement() {
                    @Override
                    protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
                        return "大家好，我是御天证道，我来自中国!";
                    }
                });
            } catch (Throwable t) {
                XposedBridge.log(t);
            }
        }

    }
}
